package cn.zhfeat.framework.shiro.init;

import java.io.Serializable;
import java.util.UUID;

import javax.servlet.ServletRequest;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.SessionIdGenerator;
import org.apache.shiro.web.subject.WebSubject;


/**
 * @description:  重写登录用户的sessionId,目前session和业务无关
 * 
 * 在登陆之前session已创建
 * 
 * @author ZhangHao
 * @date 2018年5月14日 上午11:19:49 
 * @version 1.0.0.1
 */
public class ShiroSessionIdGenerator implements SessionIdGenerator{
	
	private String REDIS_USER_SESSION_KEY = "redis_user_session_key_";


	@Override
	public Serializable generateId(Session session) {
		
		ServletRequest request = ((WebSubject)SecurityUtils.getSubject()).getServletRequest();  
        //需要的请求参数
        String account = request.getParameter("account");
        String seesionId = REDIS_USER_SESSION_KEY + account;
        //return seesionId;
        
		//sessionId  redisKey+account+时间戳
        return REDIS_USER_SESSION_KEY + account;
	}
	

}
